package cn.zqh.minio.controller;


import cn.zqh.bean.api.CommonResult;
import cn.zqh.minio.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zqh
 * @since 2023-02-21
 */
@RestController
@RequestMapping("/comment")
@Api("CommentController")
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
      * @Author: zqh
      * @Date:
      * @Description: 添加一条商品评论
    */
    @ApiOperation(value = "给商品添加评论")
    @PostMapping("createACommodityComment")
    public CommonResult createACommodityComment(String commodityId,String message){
        return commentService.creaetACommodityComment(commodityId,message);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 给店铺添加评论
    */
    @ApiOperation(value = "给店铺添加评论")
    @PostMapping("createAStoreComment")
    public CommonResult createAStoreComment(String storeId,String message){
        return commentService.createAStoreComment(storeId,message);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 通过id删除某条评论
    */
    @ApiOperation(value = "通过id删除某条评论")
    @DeleteMapping("delCommentById")
    public CommonResult delCommentById(String commentId){
        return commentService.delCommentById(commentId);
    }

    /**
     * @Author: zqh
     * @Date:
     * @Description: 查询某个商品的评论
     */
    @ApiOperation(value = "查询某个店铺或者商品的评论（style=1是商品=2是店铺）")
    @GetMapping("getCommentsBySorcid")
    public CommonResult getCommentsBySorcid(Integer style,String sorcid,Integer page,Integer size){
          return commentService.getCommentsBySorcid(style,sorcid,page,size);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 获取某个商品的评论数量
    */
    @ApiOperation(value = "查询某个商品评论的数量")
    @GetMapping("getAllCommentNumById")
    public CommonResult getAllCommentNumById(String CommodityId){
        return commentService.getAllCommentNumById(CommodityId);
    }





}

